package com.etc.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.etc.entity.Doctor;
import com.etc.service.DoctorService;

/**
 * 医生测试类
 * 
 * @author 小白
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml", "classpath:mybatis-config.xml" })
public class DoctorTestJUnit {
	@Autowired
	private DoctorService doctorService;
	/**
	 * 查询单个医生对象测试方法
	 */
	@Test
	public void getDoctorById() {
		Doctor doctor = doctorService.selectByPrimaryKey(1);
		System.out.println(doctor);

	}
	
	/**
	 * 查询所有医生对象测试方法
	 */
	@Test
	public void getDoctor() {
		List<Doctor> list= doctorService.queryBusers();
		list.forEach(System.out::println);
	}

	/**
	 * 添加医生测试方法
	 */
	@Test
	public void addDoctor() {
		Doctor doctor = new Doctor("郭中杰","男",3,5.0,"doctor-bio-1.jpg");
		int i = doctorService.insDoctor(doctor);
		System.out.println(i);
	}
	
	/**
	 * 修改医生测试方法
	 */
	@Test
	 public void updDoctor() {
		 Doctor doctor = new Doctor();
		 doctor.setDoctorid(9);
		 doctor.setDoctorname("刘兰花");
		 doctor.setDoctorsex("女");
		 doctor.setJobtime(6.0);
		 doctor.setOutpatientservicetypeid(6);
		 int i = doctorService.updDoctor(doctor);
		 System.out.println(i);
	 }
	
	/**
	 * 医生数量测试
	 */
	@Test
	public void countDoctor() {
		int i = doctorService.countDoctor();
		System.out.println(i);
	}
	
	/**
	 * 删除医生
	 */
	@Test
	public void delDoctor() {
		int i = doctorService.delDoctor(12);
		System.out.println(i);
	}
}
